﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using System.Text;
using Frame.Lib.Core.Area;

namespace Frame.Web.Common
{
    /// <summary>
    /// Summary description for AreaList
    /// </summary>
    public class AreaList : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        { 
            AreaBO area = new AreaBO();
            List<AreaInfo> list = area.GetList();
            StringBuilder sb = new StringBuilder();
            sb.Append("[");

            for (int i = 0; i < list.Count; i++)
            {
                sb.Append("{ID:" + list[i].ID + ",Name:'" + list[i].Name + "'}");
                if (i < list.Count - 1)
                {
                    sb.Append(",");
                }
            }

            sb.Append("]");

            context.Response.ContentType = "text/plain";
            context.Response.Write(sb.ToString());
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}